package com.itheima.mapper;

import com.itheima.domain.Orders;
import com.itheima.domain.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface OrdersMapper {
    @Select("select * from orders")
    /*手动指定一一映射关系*/
    @Results(id = "ordersMap",value = {
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "number",property = "number"),
            @Result(property = "user",javaType = User.class,column = "user_id",
            one = @One(select = "com.itheima.mapper.UserMapper.findById",
            fetchType = FetchType.LAZY))
    })
    @ResultMap("ordersMap")
    List<Orders> findAll();
}
